moc: handle include directives in enums
authorDebian Qt/KDE Maintainers <debian-qt-kde@lists.debian.org>
Sun, 2 Aug 2020 08:49:03 +0000 (09:49 +0100)
committerDmitry Shachnev <mitya57@debian.org>
Sun, 2 Aug 2020 08:49:03 +0000 (09:49 +0100)
Origin: upstream, https://code.qt.io/cgit/qt/qtbase.git/commit/?id=98cb33115089eebc
Last-Update: 2020-06-29

When including files, moc inserts a MOC_INCLUDE_BEGIN and
MOC_INCLUDE_END token into the token stream. Those are already handled
in the toplevel Moc::parse function, but parseEnum lacked support so
far.

Gbp-Pq: Name moc_handle_includes.diff

src/tools/moc/moc.cpp

index 50946443be764004b29db2ffbccf5dc91e3b960c..51c468ea7e1f8d8d0ec810745d12d6aee4334c07 100644 (file)
@@ -280,11 +280,21 @@ bool Moc::parseEnum(EnumDef *def)
     }
     if (!test(LBRACE))
         return false;
+    auto handleInclude = [this]() {
+        if (test(MOC_INCLUDE_BEGIN))
+            currentFilenames.push(symbol().unquotedLexem());
+        if (test(NOTOKEN)) {
+            next(MOC_INCLUDE_END);
+            currentFilenames.pop();
+        }
+    };
     do {
         if (lookup() == RBRACE) // accept trailing comma
             break;
+        handleInclude();
         next(IDENTIFIER);
         def->values += lexem();
+        handleInclude();
         skipCxxAttributes();
     } while (test(EQ) ? until(COMMA) : test(COMMA));
     next(RBRACE);